<?php
/**
 * this is a super simple app
 * using the blib
 */
// the core file inclusion
$curDir = dirname(__file__) . '/';
require_once $curDir . '../../../blib/blib.php';
// add autoload
Blib::registerLoadPath('cr', $curDir . 'core/');
// now init downloader
$d = !(empty($_GET['d']))? (int) $_GET['d'] : date('Y');
$a = !(empty($_GET['a']))? $_GET['a'] : 'nsw';
$a = strtoupper($a);

// start downloading
$db = new Cr_Download('http://www.downundernewslinks.com/crimedatabase/crimedb-' . $d . '.html', $curDir . 'tmp/');
$data = Blib::_bench('download', $db);
// search for a given state...
if (!empty($data[$a])) {
    $pcs = $data[$a];
    include 'template/main.phtml';
} else {
    echo "$a is not found in db.";
}
?>